package com.syg.transaction.controller;

import com.syg.transaction.service.Service;
import org.springframework.aop.support.AopUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author syg
 */
@RestController
public class Controller {

    @Autowired
    Service service;
    /**
     * 情况2：类被aop增强，且类中方法没有@Transactional注解
     */
    @RequestMapping(value = "/transaction",method = RequestMethod.GET)
    public void proxyClassTest(){
        // 结果是true 此时是通过AOP增强的对象
        service.save();
        boolean aopProxy = AopUtils.isCglibProxy(service);
        System.out.println("proxyClassTest result = " + aopProxy);
    }
}
